cmake_minimum_required(VERSION 3.10)

set(CMAKE_INCLUDE_CURRENT_DIR ON)                                                       # 将当前目录加入到包含目录中
set(CMAKE_AUTOMOC ON)                                                                   # 开启自动moc功能
set(CMAKE_AUTOUIC ON)                                                                   # 开启自动uic功能

set(CMAKE_PREFIX_PATH " " CACHE PATH "where you install qt?")                           # 设置QT安装包路径
find_package(Qt5Widgets CONFIG REQUIRED)                                                # 查找widget包
find_package(Qt5OpenGL)

set(SRC_DIR "${PROJECT_SOURCE_DIR}/QtApplication")                                      #设置待编译源文件目录
file(                                                                                   #利用glob命令读取所有源文件list
    GLOB_RECURSE SRC_LIST 
    LIST_DIRECTORIES false
    CONFIGURE_DEPENDS
    "${SRC_DIR}/*.c*"
    "${SRC_DIR}/*.h*"
    "${SRC_DIR}/*.ui"
)
link_directories("${PROJECT_SOURCE_DIR}/PhysLeo")                                       # 设置PhysLeo库路径
link_libraries(Qt5::Widgets Qt5::Core Qt5::Gui PhysLeo)                                                    # 设置链接至QT库 PhysLeo库
add_executable(QtApplication ${SRC_LIST})                                               #添加编译目标 可执行文件

foreach(SRC IN ITEMS ${SRC_LIST})                                                       #为VS工程添加filter 方便查看文件结构目录
    get_filename_component(SRC_PATH "${SRC}" PATH)
    file(RELATIVE_PATH SRC_PATH_REL "${SRC_DIR}" "${SRC_PATH}")
    string(REPLACE "/" "\\" GROUP_PATH "${SRC_PATH_REL}")
    source_group("${GROUP_PATH}" FILES "${SRC}")
endforeach()
                             

